import { useEffect } from "react"

export default function AtomGit() {

    const sendCodeNotice = async (taruiWindow: any,code: string) => {
        const notice = {
            ClientNotice: {
                AtomGitLoginNotice: {
                    code: code,
                }
            },
        }
        const win = taruiWindow.WebviewWindow.getByLabel("main")
        if (win != null) {
            win.emit("notice", notice)
        }
        await taruiWindow.appWindow.close()
    }

    useEffect(() => {
        const taruiWindow = require("@tauri-apps/api/window") 
        const urlParams = new URLSearchParams(location.search)
        const code = urlParams.get("code") ?? ""
        sendCodeNotice(taruiWindow,code)
    }, []);
    return (
        <div style={{ height: "200px", textAlign: "center", fontSize: "24px" }}>
            授权登陆中...
        </div>
    )
}